package org.raymond.iworks.apis.fallbackFactory;

import lombok.extern.slf4j.Slf4j;
import org.raymond.iworks.apis.ITSysRoleServiceApi;
import org.raymond.iworks.apis.common.Result;
import org.raymond.iworks.apis.vo.role.RoleCreateVO;
import org.raymond.iworks.apis.vo.role.RoleDelVO;
import org.raymond.iworks.apis.vo.role.RoleInfoVO;
import org.raymond.iworks.apis.vo.role.RoleUpdateVO;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;

@Slf4j
@Service
public class ITSysRoleServiceFallbackFactory implements FallbackFactory<ITSysRoleServiceApi> {
    @Override
    public ITSysRoleServiceApi create(Throwable throwable) {
        final String error = throwable.getMessage();
        log.error(error, throwable);
        return new ITSysRoleServiceApi() {
            @Override
            public Result create(RoleCreateVO vo, BindingResult bindingResult) {
                return Result.error(error);
            }

            @Override
            public Result update(RoleUpdateVO vo, BindingResult bindingResult) {
                return Result.error(error);
            }

            @Override
            public Result delete(RoleDelVO vo, BindingResult bindingResult) {
                return Result.error(error);
            }

            @Override
            public Result list(RoleInfoVO vo) {
                return Result.error(error);
            }

            @Override
            public Result getById(Long id) {
                return Result.error(error);
            }
        };
    }
}
